<template>
	<view class="container">
<uni-forms ref="form" :rules="{}">
			<uni-forms-item label="" name=""><uni-easyinput v-model="telephone" placeholder="请输入手机号" /></uni-forms-item>
			<uni-forms-item label="" name=""><uni-easyinput v-model="password" placeholder="请输入密码" type="password" /></uni-forms-item>
			<button type="primary" @click="register">注册</button>
		</uni-forms>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				telephone: '12345678912',
							password: '123456'
			}
		},
		methods: {
			register() {
						uni.request({
							url: 'http://localhost:8090/foodapp/user/register',
							method: 'POST',
							data: {
								telephone: this.telephone,
								password: this.password
							},
							success: res => {
								if (res.data.success) {
									uni.setStorage({
										key: 'user',
										data: JSON.stringify(res.data.data)
									});
									uni.navigateBack()
								} else {
									uni.showToast({
										title: '注册失败',
										icon: 'error'
									});
								}
							}
						});
					}
		},
		onLoad: () => {
			uni.onTabBarMidButtonTap(function(e){
				console.log(e)
				
			})
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
